home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
term.zip
/
TERM.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-02-07
|
34KB
|
1,327 lines
;
; vi:set ts=8:
;
TITLE terminal program
;
; This is version 2.2 of TERM. TERM is a terminal program that
; emulates a zenith z19 terminal. It's main feature is, that it is
; memory-resident. This allows you to run two tasks simultaneouly,
; one on your dos machine, the other on the host computer.
; You can switch easily back and forth by pressing the hotkey.
; TERM has a 2048 character receive buffer, and receives characters
; while you are doing other things under Dos. The characters are
; printed on the screen, when you switch back to the host.
; When term receives the bell character, while it's in the
; background, it will switch immediately to the foreground.
; Thus, you are notified if you receive mail (biff) or
; someone wants to talk with you
;
; Mail problems, suggestions or bug reports to:
;
; Karl Gegenfurtner
;
;arpa: karl@hipl.psych.nyu.edu
;uucp {ihnp4|seismo|allegra}!cmcl2!xp!hipl!karl
;usps: New York University
; Dept. of Psychology
; 6 Washington Place 8th floor
; New York, NY 10003
;
; In the case, that you make major improvements to term,
; like adding file transfer capabilities, I really would
; want to get copy of the program, before you sell it.
;
; History:
; - fall 1986: Version 1.0 by Hans Irtel, Uni Regensburg
; output is via ansi driver int 29h
; send xoff/xon when switching
; - spring 87: Version 2.0 by Karl Gegenfurtner, New York University
; added z19 emulation
; rewrote the comm-initialization routines
; made the dos interface well-behaved
; put xon/xoff into interrupt routine
; - april 87: Version 2.1 Wed Apr 01 18:35:05 1987
; added alarm feature
; added support for monochrome card
; - april 87: Version 2.2 Thu Apr 02 19:12:39 1987
; dynamically allocate rxbuffer to reduce prog size
; fix cexit bug (restore comm int)
; fix the monochrome cursor
; add keypad enter pseudo sequences for xp
; moved cinit and cexit to non-resident part
; made some equates to variables for install
; fix the silly bug in kb_int, which caused two
; instances of term running simultaneously
; Wed Apr 08 20:06:07 1987
; fixed init code in enab
;
;
; Future:
; - write installation program
; - add some primitive functions for reinitializing etc.
;
;
;
; installation equates
;
Ifgcolor equ 74h
Ibgcolor equ 47h
Iswitchcode equ 3400h ; 3400h is F12 on an AT
; 4400 is F10 on a PC
; 7000 is alt-f9 on a PC
Itport equ 2 ; comm port to use
Iline_par equ 11100011b
; comm line parameters
; 8 data bits, 1 stopbit, no parity
logo equ "HI" ; for Hans Irtel
terminal_page equ 1 ; alternate video page
show_ctrl equ 0 ; show ctrl chars as ^x
;
; other useful defines
;
xon equ 11h
xoff equ 13h
eoi equ 20h ; non-specific eoi
c1mask equ 0efh
c2mask equ 0f7h
c1off equ 10h
c2off equ 08h
c1base equ 03f8h
c2base equ 02f8h
c1int equ 0ch
c2int equ 0bh
int_enable equ 1
line_control equ 3
modem_control equ 4
line_status equ 5
buflen equ 2048
maxcount equ buflen-64
lowcount equ 128
chesc equ 27
bel equ 7
cr equ 13
lf equ 10
bs equ 8
tab equ 9
screen equ 10h ; bios screen call
screensize equ 25*80
timer equ 40h ; timer port
bel_prt equ 61h ; speaker control
crt_status equ 3dah ; crt status port
disp_enb equ 8 ; display enable bit
code_seg segment
assume cs:code_seg, ds:code_seg, es:code_seg
org 100H
terminal proc far
jmp install
terminal endp
;
; the first data may be changed by the installation program
;
fgcolor DB Ifgcolor
bgcolor DB Ibgcolor
tport DW Itport
line_par DB Iline_par
switchcode DW Iswitchcode
;
; data for routines
;
old_com1 DW 00H
old_com2 DW 00H
kb_bios label dword
old_kb1 DW 00H
old_kb2 DW 00H
rxbuffer DW offset lastbyte
buf_end DW offset lastbyte + buflen
head DW offset lastbyte
tail DW offset lastbyte
tflag DB 0
alarm DB 0
bw DB 0
count DW 0
txoff DB 0
rxoff DB 0
rxfull DB 0
cbase DW 0
cmask DB 0
coff DB 0
cint DB 0
freemem DW offset lastbyte + buflen
usersave DW offset lastbyte + buflen + 2
termsave DW offset lastbyte + buflen + 2 + screensize * 2
mofreemem DW offset lastbyte + buflen + 2 + screensize * 2 * 2
usercursor DW 0
termcursor DW 0
;
; stuff for screen routines
;
trnctl equ 80h
lnwrap equ 40h ; line wrap enabled.
line25 equ 20h
IF show_ctrl
flags db 0C0h
ELSE
flags db 40h ; status flags...
ENDIF
cursor dw 0
esc_ch db ?
argadr dw ? ; address of arg blk
spctab db chesc, cr, lf, bs, tab, bel
lspctab equ $-spctab
spcjmp dw outesc,outcr,outlf,outbs,outtab,outbel ; must match spctab
esctab db 'YABCDEFGHIJKLM'
db 'NOZ@[pq<vw'
db 'jk'
db 'xy'
db '>='
lesctab equ $-esctab
; escjmp must parallel esctab above
escjmp dw movcur,curup,curdwn,currt,outbs,clrscr,outign,outign,curhom
dw revind,clreow,clreol,inslin,dellin,delchr,noins
dw vtident,entins,doansi
dw invvid,nrmvid,outign,dowrap,nowrap
dw savecur,restcur
dw smarg, rmarg
dw escign, escign
coord dw ?
insmod db ?
wcoord dw ?
ttstate dw offset scrini
curattr db ? ; current attribute
ansarg db ? ; ansi argument value
igncnt db ? ; # of chars to ignore
beldiv dw 2dch ; 550 hz?
crt_mode db ?
crt_cols db 80
crt_lins db 24
crt_page db 0
low_rgt dw ? ; lower right corner of window
oldcur dw 0 ; save'd cursor position
;---------------------------------------------------------------------
; communication interface routines:
; cinit: initialize interrupts of port in dx
; cgetch: get next charcacter from buffer to al
; cputch: put character in al out on comm port
; cexit: reset interrupts
; rxchar: interrupt service routine
;----------------------------------------------------------------------
;
; interface routines
;
; cinit moved to non-resident part
;
; second entry point just for a re-init
;
enab proc near
;
; set up the serial card
;
mov dx, cbase
add dx, line_control
mov al, 3
out dx, al
mov dl, 0f8h
in al, dx
;
; start RS232 interrupt
;
mov dx, cbase
add dx, int_enable
mov al, 1
out dx, al
mov dl, 0fch
mov al, 0fh
out dx, al
;
; set up 8259 interrupt controller
;
cli
in al, 21H
and al, cmask
out 21H, al
sti
;
; done
;
ret
enab endp
;
; cexit moved to the non-resident part
;
cgetch proc near
cmp count, 0
je gc3
mov bx, head
mov al, [bx]
inc bx
cmp bx, buf_end
jne gc1
mov bx, rxbuffer
gc1: mov head, bx
cli ; no interrupts during change of count
dec count
sti
;
; check for leaving buffer full state
;
test rxfull, 80h
jz gc2
;
; we are in rxfull state
;
cmp count, lowcount
ja gc2
;
; buffer is free to receive new charcters now
;
push ax
mov ax, xon ; send XON protocol
call txchar
mov rxfull, 0
mov rxoff, 0
pop ax
gc2: mov ah, 0
ret
gc3: mov ax, -1
ret
cgetch endp
cputch proc near
test txoff, 80h
jnz t0
call txchar ; character in al
jmp t1
;
; in txoff state: return without sending
;
t0: mov ax, -1
t1: